package com.htc.model.request;

public class ProductRequest extends PageRequest{
	private Integer pid;
	private String cpid;
	private String pname;
	private String cname;
	private String status;
	private String cid;
	private Integer consumer_id;
	
	
	public Integer getPid() {
		return pid;
	}


	public void setPid(Integer pid) {
		this.pid = pid;
	}


	public String getPname() {
		return pname;
	}


	public void setPname(String pname) {
		this.pname = pname;
	}


	public String getCname() {
		return cname;
	}


	public void setCname(String cname) {
		this.cname = cname;
	}
	
	


	public String getStatus() {
		return status;
	}


	public void setStatus(String status) {
		this.status = status;
	}

	

	public String getCid() {
		return cid;
	}


	public void setCid(String cid) {
		this.cid = cid;
	}
	
	


	public Integer getConsumer_id() {
		return consumer_id;
	}


	public void setConsumer_id(Integer consumer_id) {
		this.consumer_id = consumer_id;
	}
	
	


	public String getCpid() {
		return cpid;
	}


	public void setCpid(String cpid) {
		this.cpid = cpid;
	}


	public String convertWhereStr() {
		StringBuffer where = new StringBuffer(" where 1=1 ");
		if(pname!=null&&(!pname.equals("null"))&&pname.trim().length()!=0) {
			where.append(" and pname like '%"+pname+"%'");
		}
		if(cname!=null&&cname.trim().length()!=0) {
			where.append(" and cname like '%"+cname+"%'");
		}
		if(status!=null&&status.trim().length()!=0) {
			where.append(" and status = '"+status+"'");
		}
		if(cid!=null&&(!cid.equals("null"))&&cid.trim().length()!=0) {
			where.append(" and product.cid = '"+cid+"'");
		}
		if(pid!=null) {
			where.append(" and product.pid="+pid);
		}
		if(consumer_id!=null) {
			where.append(" and product.consumer_id="+consumer_id);
		}
		if(cpid!=null&&cpid.length()>0&(!cpid.equals("null"))) {
			where.append(" and product.cid in(select cid from classes where pid="+cpid+")");
		}
		return where.toString();
	}
	
	
	
}
